/*
 * @Date: 2021-09-12 19:21:05
 * @Author: Acckno1
 * @LastEditTime: 2021-09-12 19:23:54
 * @Description: 
 */
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

const int N = 10010;

struct Person{
    int arr_time;
    int ser_time;
    
    bool operator < (const Person & p) const{
        return arr_time < p.arr_time;
    }
}person[N];

int n, m;

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i ++ ) {
        int hour, minute, second, ser_time;
        scanf("%d:%d:%d %d", &hour, &minute, &second, &ser_time);
        int arr_time = hour * 60 * 60 + minute * 60 + second;
        person[i] = {arr_time, ser_time * 60};
    }
    
    sort(person, person + n);
    priority_queue<int, vector<int>, greater<int>> windows;
    
    for (int i = 0; i < m; i ++ ) windows.push(8 * 3600);
    
    int sum = 0, cnt = 0;
    for (int i = 0; i < n; i ++ ) {
        Person p = person[i];
        int w = windows.top();windows.pop();
        if (p.arr_time > 17 * 3600) break;
        
        int start_time = max(p.arr_time, w);
        sum += start_time - p.arr_time;
        cnt ++ ;
        windows.push(start_time + p.ser_time);
    }
    
    printf("%.1lf\n", (double)sum * 1.0 / cnt / 60);
    return 0;
}